Ext.define('PJ.view.messagemanagement.WindowFrame', {
    extend: 'Ext.window.Window',
    layout: 'border',
    modal: true,// 开启不允许点击其他组件
    resizable: false,
    
    width: 850,
    height: 578,
    parentId: null,
    buttonAlign: "center",
    // 必须增加这段，强制提前加载类，这样才可以使用简写
    requires: ['PJ.view.messagemanagement.RightFrame', 'PJ.view.messagemanagement.DepartmentTree'],
    
    initComponent: function(){
        this.items = [{
            region: 'center',
            xtype: 'messagemanagementRightFrame',
            receiveUserNames:this.receiveUserNames,
            receiveUserIds:this.receiveUserIds,
            userType:this.userType,
            loginIds:this.loginIds,
            deptNames:this.deptNames
        },{
            region: 'west',
            width: 250,
            xtype: "deptTree",
            receiveUserNames:this.receiveUserNames,
            receiveUserIds:this.receiveUserIds,
            loginIds:this.loginIds,
            deptNames:this.deptNames,
            collapsible: true
        }];
        
        this.buttons = [{
            text: '确定',
            scope: this,
            handler: this.PreClose
        }];
        this.callParent(arguments);
    },
    PreClose: function(){
        var me = this;
        var edit = this.edit;
        var baseForm = edit.up('form').getForm();
        var receiveUserNames = baseForm.findField('receiveUserName');
        var receiveUserIds = baseForm.findField('receiveUserId');
        var loginIds=baseForm.findField('loginIds');
        var deptNames=baseForm.findField('deptNames');
        var store = me.down('messagemanagementChoisedList').getStore();
        var jName = new Array();
        var JId = new Array();
        var JloginId=new Array();
        var JdepName=new Array();
        store.each(function(record){
            jName.push(record.data.userName);
            JId.push(record.data.userId);
            JloginId.push(record.data.loginID);
            JdepName.push(record.data.deptName);
        });
        receiveUserNames.setValue(jName);
        receiveUserIds.setValue(JId);
        loginIds.setValue(JloginId);
        deptNames.setValue(JdepName);
        me.close();
    },
    listeners: {
        // window打开后的事件,刷新已选菜单grid
        show: function(){
            var loadMask = new Ext.LoadMask(this, {
                msg: orchid_lang.promptWindowInfo.loadingText
            });
            this.down("messagemanagementPreChoisedList").loadMask = loadMask;
            this.down("messagemanagementChoisedList").loadMask = loadMask;
            var store = this.down("messagemanagementPreChoisedList").getStore();
       		var receiveUserIds= this.receiveUserIds.getValue();
			var newParams = {
	    		//默认西城区为根节点
				deptId:'1854369',
				noUserIDs:receiveUserIds
            };
            // 4.0强制更改store参数写法
            var params = store.proxy.extraParams;
            Ext.apply(params, newParams);
            // grid加载生效
            store.isLoad = true;
            store.load();
        },
    }
});
